<?php
namespace app\admin\controller;


/**
 * @title 合作新闻
 * @description 接口说明
 * @group admin
 * @header name:authorization require:1 default: desc:登陆的token
 */
class PartnerNews extends Base
{
    protected $_order = 'id desc';

    /**
     * @title 获取
     * @description 接口说明
     * @author hardy
     * @url /admin/PartnerNews
     * @method GET
     *
     * @return content:新闻内容
     */
    public function gets()
    {
        $this->getOne(1, $this->controller);
    }    protected function _searchPage(&$where)
{
    $data = input('get.');
    $key = 'title';
    if(!empty($data[$key])){
        $where[] = [$key,'like', "%{$data[$key]}%"];
    }
    $key = 'tags';
    if(!empty($data[$key])){
        $where[] = [$key,'like', "%{$data[$key]}%"];
    }
    $key = 'auth';
    if(!empty($data[$key])){
        $where[] = [$key,'like', "%{$data[$key]}%"];
    }
    $key = 'publish';
    if(isset($data[$key]) && $data[$key] !== ''){
        $where[] = [$key,'=', $data[$key]];
    }
    $key = 'cate_id';
    if(!empty($data[$key])){
        $where[] = [$key,'=', $data[$key]];
    }

}
    public function create(){}
    /**
     * @title 修改
     * @description 接口说明
     * @author hardy
     * @url /admin/PartnerNews
     * @method put
     *
     *
     * @param name:content type:string require:1 default: other: desc:合作新闻内容
     *
     * @return content:新闻内容
     */
    public function update(){
        $data = input('put.');
        $data['id'] = 1;
        $validate = Validate($this->controller);
        if (!$validate->checkRuleByData($data)) {
            $this->responseFail($validate->getError());
        }
        $model = model($this->controller);
        $r = $model->updateSave($data);
        if ($r == false){
            $this->responseFail($model->getError());
        }
        $this->getOne(1);
    }
    public function delete(){}
}